<template>
  <rx-dialog @handOk="handRetrieveTask" @cancel="cancel" order="top" btnalign="right">
    <a-form-model ref="form" :model="form" >
      <a-row>
        <a-col :span="24">
          <a-form-model-item :labelCol="labelCol1" :wrapperCol="wrapperCol1" :label="i18n('fetchPage.taskName','任务名称')">
            {{subject}}
          </a-form-model-item>
        </a-col>
      </a-row>

      <a-row>
        <a-col :span="24">
          <a-form-model-item :labelCol="labelCol1" :wrapperCol="wrapperCol1" :label="i18n('fetchPage.opinion','意见')" prop="opinion">
            <a-textarea v-model="form.opinion" style="width: 100%"/>
          </a-form-model-item>
        </a-col>
      </a-row>

      <a-row>
        <a-col :span="24">
          <a-form-item :label="i18n('fetchPage.msgTypes','通知方式')" :labelCol="labelCol1" :wrapperCol="wrapperCol1"  prop="msgTypes">
            <a-checkbox-group :options="msgOptions" v-model="form.msgTypes">
            </a-checkbox-group>
          </a-form-item>
        </a-col>
      </a-row>

    </a-form-model>
  </rx-dialog>
</template>

<script>
    import BpmPublicApi from '@/api/bpm/core/BpmPublicApi'
    import {BaseFormModel, RxDialog,Dialog,Util} from '@lowcode/jpaas-common-lib';
    import BpmTaskTransferApi from "@/api/bpm/core/bpmTaskTransfer.js";

    export default {
        name: "bpm-retrieve-task",
        props:{
            subject:String,
            taskId:String,
            layerid: String,
            lydata: Object,
            destroy:Function
        },
        mixins:[BaseFormModel],
        components: {
            RxDialog,
        },
        data(){
            return {
                msgOptions:[],
                form:{
                    opinion:"",
                    msgTypes:[]
                },

            }
        },
        created(){
            this.init();
        },
        methods: {
            i18n(name,text,key){
                return this.$ti18(name,text,"MyTransOutTask",key);
            },
            init(){
                this.form.taskId=this.taskId;
                BpmPublicApi.getMessageHandler().then(res=>{
                    res.forEach((val)=> {
                        this.msgOptions.push({label:val.name,value:val.type})
                    })
                })
            },
            handRetrieveTask(e){
                this.form.msgTypes=this.form.msgTypes.join(",");
                var self=this;
                this.$confirm({
                    title: this.$ti18('rxMsa.actionTips','操作提示'),
                    zIndex: 20000,
                    content: self.i18n('msa.fetchTips','确认取回代办任务吗?'),
                    okText: this.$ti18('rxForm.ackBtn','确认'),
                    cancelText: this.$ti18('rxForm.cancelBtn','取消'),
                    onOk() {
                        BpmTaskTransferApi.doRetrieveTask(self.form).then(res=>{
                            Util.closeWindow(self,"ok")
                        })
                    },
                    onCancel() {
                        e.loading=false;
                        self.form.msgTypes=self.form.msgTypes.split(",");
                    }
                })
            }
        }
    }
</script>

<style scoped>

</style>